{include_file name="Public/header" title="文章列表"}



<!-- begin #content -->
<div id="content" class="content">

    <!-- begin page-header -->
    <!-- end page-header -->

    <!-- begin search -->
    <div class="panel panel-inverse" data-sortable-id="ui-typography-10">
        <div class="panel-heading">
            <h4 class="panel-title">条件搜索</h4>
        </div>
        <div class="panel-body">
            <form class="form-inline" action="{U("{CONTROLLER_NAME}/index")}" method="GET">
                <!--标题搜索-->
                <div class="form-group m-r-10">
                    <label class="control-label">标题</label>
                    <input type="text" class="form-control" name="title" value="{$search.title}" placeholder="输入标题">
                </div>
                <!--发布者搜索-->
                <div class="form-group m-r-10">
                    <label class="control-label">发布者</label>
                    <input type="text" class="form-control" name="nick_name" value="{$search.nick_name}" placeholder="输入发布者">
                </div>
                <!--时间区间搜素-->
                <div class="form-group m-r-10">
                    <label class="control-label">发布时间</label>
                    <input type="text" name="start_time" readonly="" class="form-control js_start_time width-xs" value="{$search.start_time}">
                    <input type="text" name="end_time" readonly="" class="form-control js_end_time width-xs" value="{$search.end_time}">
                </div>
                <!--状态搜索-->
                <div class="form-group m-r-10">
                    <label>状态</label>
                    <select class="form-control" name="status">
                        <option value='0'>不限</option>
                        <option value="1"{if $search.status == 1}selected{/if}>正常</option>
                        <option value="2"{if $search.status == 2}selected{/if}>禁用</option>
                    </select>
                </div>


                <button type="submit" class="btn btn-sm btn-primary m-l-5">搜索</button>
            </form>
        </div>
    </div>
    <!-- end search -->

    <!-- begin row -->
    <div class="row">
        <!-- begin col-12 -->
        <div class="col-md-12">
            <!-- begin panel -->
            <div class="panel panel-inverse">
                <div class="panel-body">
                    <div class="table-responsive">
                        <table id="data-table" class="table table-striped table-bordered">

                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>标题</th>
                                <th>封面</th>
                                <th>发布者</th>
                                <th>添加时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $list as $v}
                            <tr class="odd gradeX">
                                <td>{$v.id}</td>
                                <td>{$v.title}</td>
                                <td><img src="{_image($v.cover)}" width="150px" height="150px"></td>
                                <td>{admin_helper::get_nick_name($v.admin_id)}</td>
                                <td>{$v.add_time}</td>
                                <td>{if $v.status}正常{else}禁用{/if}</td>

                                <td>
                                    <a class="btn btn-success  btn-xs m-r-5" href="{U("{CONTROLLER_NAME}/edit?id={$v.id}")}">编辑</a>
                                    <a class="btn btn-danger  btn-xs m-r-5 js_delete" href="javascript:void(0);" data-id="{$v.id}">删除</a>
                                </td>

                            </tr>
                            {foreachelse}
                                    <tr><td colspan="12">暂无相关信息</td></tr>
                            {/foreach}

                            </tbody>
                        </table>
                        {include_file name="Public/page"}
                    </div>
                </div>
            </div>
            <!-- end panel -->
        </div>
        <!-- end col-12 -->
    </div>
    <!-- end row -->
</div>
<!-- end #content -->

<!--日期、时间选择插件，更多用法参考http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm-->
<script type="text/javascript" src="{STATIC_PLUG}/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="{STATIC_PLUG}/bootstrap-datetimepicker/js/bootstrap-datetimepicker.zh-CN.js"></script>

<script>
    $(function(){
        //时间选择插件
        $(".js_start_time,.js_end_time").datetimepicker(
                {
                    language:  'zh-CN',
                    format: 'yyyy-mm-dd hh:ii:ss',
                    weekStart: 1,
                    todayBtn:  1,
                    autoclose: 1,
                    todayHighlight: 1,
                    startView: 2,
                    minView: 2,
                    forceParse: 0,
                    endDate:"{date('Y-m-d')}"
                }
        );

        //删除
        $(".js_delete").click(function(){
            var id = $(this).data('id');
            var url = "{U("{CONTROLLER_NAME}/delete")}";
            if(confirm('一旦删除，无法恢复，你确认删除吗？')==true){
                $.post(url, { id:id }, function(msg){
                    if(msg == 'ok'){
                        location.reload();
                    }else{
                        alert(msg);
                    }
                }, 'json');
            }
        });

    });
</script>
{include_file name="Public/footer"}